package com.joysuch.wwyt.risk.repository;

import com.joysuch.wwyt.risk.entity.RiskEvaluationControl;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface RiskEvaluationControlDao extends JpaRepository<RiskEvaluationControl, Long> {

    @Query(value = "select * from wwyt_risk_evaluation_control where `name` = ?1 and delete_flag = '0' ", nativeQuery = true)
    RiskEvaluationControl findByName(String name);

    @Query(value = "select * from wwyt_risk_evaluation_control where `name` = ?1 and org_code like concat(?2,'%') and tenent_id = ?3 ", nativeQuery = true)
    RiskEvaluationControl findByNameAndCompany(String name, String orgCode, Long tenentId);

    @Query(value = "select * from wwyt_risk_evaluation_control where `name` = ?1 and org_code like ?2% and tenent_id =?3 and delete_flag = '0' limit 1 ", nativeQuery = true)
    RiskEvaluationControl findByNameAndOrgCodeAndTenentId(String name, String orgCode, Long tenentId);
}
